#include <windows.h>
#include "GameApp.h"
#include <iostream>
#include <sstream>
#include <string>

#pragma comment(lib, "dxgi.lib")

template<class T>
using ptr = Microsoft::WRL::ComPtr<T>;

int WINAPI wWinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrev,
    PWSTR pCmdLine,
    int args
) {
    ptr<IDXGIFactory> pFac = nullptr;
    CreateDXGIFactory(
        __uuidof(pFac.Get()),
        reinterpret_cast<void**>(pFac.GetAddressOf())
    );
    ptr<IDXGIAdapter> pAdapter;
    pFac->EnumAdapters(0, pAdapter.GetAddressOf());
    ptr<ID3D11Device> pDevice;
    ptr<ID3D11DeviceContext> pDeviceContext;
    D3D_FEATURE_LEVEL featureLevels[] = {
        D3D_FEATURE_LEVEL_11_1
    };
    HRESULT hr = D3D11CreateDevice(
        pAdapter.Get(),
        D3D_DRIVER_TYPE_UNKNOWN,
        nullptr,
        D3D11_CREATE_DEVICE_DEBUG,
        nullptr,
        6,
        D3D11_SDK_VERSION,
        pDevice.GetAddressOf(),
        featureLevels,
        pDeviceContext.GetAddressOf()
    );
    std::wstring s;
    std::wstringstream ss;
    ss << SUCCEEDED(hr);
    ss >> s;
    MessageBox(nullptr, s.c_str(), L"", 0);
    return 0;
}